#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

# parâmetros iniciais
while True:
    bignum = 50
    n_iter = 0
    with display_block('Entradas'):
        h = (One * oneof(1, 2, 3, 4)) / oneof(1, 2, 3, 4)
        R = sqrt(h)
        c1 = (One * oneof(1, 1, -1) * oneof(1, 2, 3, 4, 5, 6)) / oneof(1, 2, 3, 4, 5, 6)
        c2 = (One * oneof(1, 1, -1) * oneof(1, 2, 3, 4, 5, 6)) / oneof(1, 2, 3, 4, 5, 6)
        c3 = (One * oneof(1, 1, -1) * oneof(1, 2, 3, 4, 5, 6)) / oneof(1, 2, 3, 4, 5, 6)
        Fx, Fy, Fz = (v * c for v, c in zip([x, y, z], [c1, c2, c3]))

    # Resultados
    with display_block('Resultados'):
        Phi = (c1 + c2 + c3) * pi * h ** 2 / 2
        PhiParab = Phi - c3 * pi * h ** 2
        PhiMix = -Phi + 2 * c3 * pi * h ** 2
        PhiJacob = c3 * pi * h ** 2 + (c1 + c2 + c3) * pi * h ** 2 / 2
        PhiQuad = c3 * pi * h ** 2 + (16 * h ** 2 * c2 - 8 * h ** 2 * c3 + 16 * h ** 2 * c1) / 3 * pi
        PhiElem = Phi + 2 * pi * h ** 2 / 2

        _resps = set([ Phi, PhiParab, PhiMix, PhiJacob, PhiQuad, PhiElem ])
        if len(_resps) != 6:
            continue
        else:
            _cont_loop = True
            for _resp in _resps:
                num, den = (_resp / pi).as_numer_denom()
                if num > bignum or den > bignum:
                    break
            else:
                _cont_loop = False
            if _cont_loop:
                continue

            _distr = []
            _resps = list(_resps)
            while len(_distr) < 2:
                new = oneof(*_resps) * (One * oneof(1, 2, 3, 4)) / oneof(1, 2, 3, 4)
                if new not in _resps:
                    _distr.append(new)
            distr1, distr2 = _distr

        n_iter += 1
    break
